import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../controllers/tabs_controller.dart';

class TabsView extends GetView<TabsController> {
  const TabsView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Obx(() => Scaffold(
          body: PageView(
            controller: controller.pageController,
            onPageChanged: (value) {
              controller.setCurrentIndex(value);
            },
            physics: const NeverScrollableScrollPhysics(),
            children: controller.pages,
          ),
          bottomNavigationBar: BottomNavigationBar(
              currentIndex: controller.currentIndex.value,
              onTap: (value) {
                controller.setCurrentIndex(value);
                controller.pageController.jumpToPage(value);
              },
              type: BottomNavigationBarType.fixed,
              fixedColor: Colors.red,
              unselectedFontSize: 14.0,
              items: const [
                BottomNavigationBarItem(
                    icon: Icon(Icons.home_outlined),
                    activeIcon: Icon(Icons.home),
                    label: "首页"),
                BottomNavigationBarItem(
                    icon: Icon(Icons.category_outlined),
                    activeIcon: Icon(Icons.category),
                    label: "分类"),
                BottomNavigationBarItem(
                    icon: Icon(Icons.design_services_outlined),
                    activeIcon: Icon(Icons.design_services),
                    label: "服务"),
                BottomNavigationBarItem(
                    icon: Icon(Icons.shopping_cart_checkout_outlined),
                    activeIcon: Icon(Icons.shopping_cart_rounded),
                    label: "购物车"),
                BottomNavigationBarItem(
                    icon: Icon(Icons.person_2_outlined),
                    activeIcon: Icon(Icons.person_2),
                    label: "我的"),
              ]),
        ));
  }
}
